﻿using Jayden.Dll.Sc2.Descriptions;
using Jayden.Dll.Web.HtmlControls;

namespace Jayden.Dll.Web.Controls.Sc2
{
	public class EntityDescriptionTable : DataTable<EntityDescription>
	{

		public override void Load(System.Xml.XmlNode node, HtmlControlLoader loader)
		{
			base.Load(node, loader);

			AddColumn(null, 20, delegate(EntityDescription value, Column column, int index) { return OneControl(new Img(value.Race.Name, "/Images/Icons/Sc2/" + value.Race.Id + ".png") { Title = value.Race.Name }); }, null);
			AddColumn(null, 20, delegate(EntityDescription value, Column column, int index) { return OneControl(new Img(value.IconId, "/Images/Icons/Sc2/" + value.IconId + ".gif") { Title = value.Name, Class = "icon" }); }, null);
			AddColumn("Name", 250, delegate(EntityDescription value, Column column, int index) { return OneControl(new A(value.Name, "/drafts/starcraft2/" + value.Race.Id + "/" + value.Id + ".html")); }, null);
			AddColumn("Type", 60, delegate(EntityDescription value, Column column, int index) { return ParseText(value.Type.ToString()); }, null);
			AddColumn("Mineral", 60, delegate(EntityDescription value, Column column, int index) { return ParseText(value.Mineral == 0 ? "-" : value.Mineral.ToString()); }, null);
			AddColumn("Vespene", 60, delegate(EntityDescription value, Column column, int index) { return ParseText(value.Vespene == 0 ? "-" : value.Vespene.ToString()); }, null);
			AddColumn("Time", 60, delegate(EntityDescription value, Column column, int index) { return ParseText(value.Time == 0 ? "-" : value.Time.ToString()); }, null);
			AddColumn("Food", 60, delegate(EntityDescription value, Column column, int index) { return ParseText(value.Supply == 0 ? "-" : value.Supply.ToString()); }, null);
			//AddColumn("Count", 60, delegate(EntityDescription value, Column column, int index) { return ParseText(value.Count == 1 ? "-" : value.Count.ToString()); }, null);
			AddColumn("Level", 60, delegate(EntityDescription value, Column column, int index) { return ParseText(value.Level == 0 ? "-" : value.Level.ToString()); }, null);
			AddColumn("Min. Time", 60, delegate(EntityDescription value, Column column, int index) { return ParseText(value.MinTime == 0 ? "-" : value.MinTime.ToString()); }, null);
		}
	}
}
